package com.xiaohui.user.controller;

import com.xiaohui.redis.util.RedisShareLockUtil;
import com.xiaohui.tool.ExportWordUtil;
import com.xiaohui.user.excel.SysUserExcelExport;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@Slf4j
public class TestController {
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private RedisShareLockUtil redisShareLockUtil;

    @Autowired
    private SysUserExcelExport sysUserExcelExport;


    @GetMapping("/test")
    public String test(String message){
        return "Message: '" + message + "' sent.";
    }

    @GetMapping("/testRedis")
    public void testRedis(){
        redisTemplate.opsForValue().set("test","test");
    }

    @GetMapping("/testRedisShareLock")
    public void testRedisShareLock(){
        boolean lock = redisShareLockUtil.lock("xiaohui1", "123", 10000L);
        System.out.println(lock);
    }

    @GetMapping("/testLog")
    public void testLog(String a){

        for (int i = 0; i < 100; i++){
            log.info("打印" + a +"{}条", i);
        }
    }

    @GetMapping("/testExport")
    public void testExport() throws Exception {
        Map<String, Object> map = new HashMap<>();
        sysUserExcelExport.exportExcel("用户列表", map);
    }

}
